package cn.wp.common.core.plugin.template;

import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
import org.thymeleaf.dialect.IDialect;
import org.thymeleaf.spring5.SpringTemplateEngine;
import org.thymeleaf.spring5.dialect.SpringStandardDialect;

/**
 * 模板引擎
 */
@Component
public class SimpleStringTemplateConfiguration {

    @Bean
    public SimpleSpringTemplateEngine simpleSpringTemplateEngine(){
        /*// Html解析器
		StringTemplateResolver resolverHtml = new StringTemplateResolver();
		resolverHtml.setCacheable(true);
		resolverHtml.setTemplateMode(TemplateMode.HTML);
		// 文本解析器
		StringTemplateResolver resolverText = new StringTemplateResolver();
		resolverText.setCacheable(true);
		resolverText.setTemplateMode(TemplateMode.TEXT);*/

        SimpleSpringTemplateEngine templateEngine = new SimpleSpringTemplateEngine();
        IDialect dialect = new SpringStandardDialect();
        templateEngine.setDialect(dialect);

        // 添加两个解析器
        //templateEngine.addTemplateResolver(resolverHtml);
        //templateEngine.addTemplateResolver(resolverText);
        return templateEngine;
    }

}